<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>
        // let url = 'https://api.apiopen.top/getJoke?page=1&count=2&type=video';
       let url = 'http://47.115.155.251/user/09';
        let  getData = getAjax(url)
        function getAjax(url){
            return new Promise(function(reslove,reject){
                let xhr = new XMLHttpRequest();
                console.log(xhr);
                let httpurl = url
                xhr.open('GET',httpurl);
            
            xhr.onreadystatechange = function(){
                 if (xhr.status == 200&& xhr.readyState == 4 ) {
                reslove(xhr)
            }else if (xhr.status != 200 && xhr.readyState == 4 ) {
                reject(xhr)
            }
            }
           
            xhr.send()
            })


        }
        console.log(getData);
        getData.then(res=>{
            let result = JSON.parse(res.response)
            console.log(res);
            console.log(result);
        })
        


        function getAjax2(url){
         let xhr = new XMLHttpRequest();
        // console.log(xhr);

        xhr.open('GET',url)

        xhr.onredaystatechange = function(){
            if (xhr.readyState == 4 && xhr.status==200) {
             
            }else if (xhr.readyState == 4 && xhr.status!=200) {
              
            }

        }

        xhr.send()
        }

        // let send = 

        fetch(url).then(res=>{
            console.log(res);
        let result = res.json();
        console.log(result);
        result.then(res=>{
            console.log(res);
        })
        })

        


























    </script>
    
</body>
</html>